# -*- coding: utf-8 -*-
"""
@File: main.py
@Time: 2022/01/06 17:22
@Author: 鹄望潇湘
@desc: 学术规范成绩录入脚本，将特定人员的成绩设置为不通过

"""


from pymouse.windows import PyMouse
from pykeyboard.windows import PyKeyboard
import time
import pandas as pd
import tqdm

mouse = PyMouse()
board = PyKeyboard()

old_pos = mouse.position()
time.sleep(0.1)
mouse.move(20, 35)
time.sleep(0.1)
mouse.click(20, 35)
time.sleep(0.1)
# 激活成绩录入窗口

board.tap_key(board.tab_key, 1)  # 将焦点切换至学生学号输入框
data = pd.read_excel("C:\\Users\\12703\\Desktop\\未提交作业或文件名不包含学号列表-学术规范与创新创业.xlsx", sheet_name=3)
data = data["学号"].astype(str).values

progress = tqdm.tqdm(total = len(data))
for item in data:
    board.type_string(item)
    time.sleep(0.3)
    board.tap_key(board.enter_key, 1)
    time.sleep(4.0)
    board.tap_key(board.tab_key, 11)
    time.sleep(0.5)
    board.tap_key(board.up_key, 1)  # 成绩设置为不通过
    time.sleep(0.3)
    mouse.click(174, 129, 1)  # 点击保存按钮
    time.sleep(1.2)
    board.tap_key(board.enter_key, 1)  # 关闭确认框
    time.sleep(2.0)
    board.tap_key(board.tab_key, 1)  # 重新切换到输入学号的输入框
    progress.update(1)
    pass
progress.close()

mouse.move(old_pos[0], old_pos[1])
print("已结束")